# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_gemname=mail-gpg
pkgname=ruby-mail-gpg
pkgver=0.4.4
pkgrel=2
pkgdesc='GPG/MIME extension for the Ruby Mail Library'
url='https://github.com/jkraemer/mail-gpg'
arch=('any')
license=('MIT')
depends=('ruby' 'ruby-gpgme' 'ruby-mail' 'ruby-rdoc')
options=('!emptydirs')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/jkraemer/mail-gpg/archive/v${pkgver}.tar.gz
        ${pkgname}-${pkgver}.tar.gz.asc::https://github.com/jkraemer/mail-gpg/releases/download/v${pkgver}/mail-gpg-${pkgver}.tar.gz.asc)
sha512sums=('bf5e937c4d5c95ce35a7f30b276f023be0d4be46b0b1ffdb3550cbbb8b6094d5c2f90e60322ddb0b61f02c75aa6d3ed1fbd7c8e24a5d0ee50d99422ae04ae183'
            'SKIP')
validpgpkeys=('C3880ACE6187419B177C472E08625A14CE3CDDAA') # Jens Kraemer <jk@jkraemer.net>

prepare() {
  cd ${_gemname}-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec
  sed 's|git ls-files|find -type f|' -i ${_gemname}.gemspec
}

build() {
  cd ${_gemname}-${pkgver}
  gem build ${_gemname}.gemspec
}

package() {
  cd ${_gemname}-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" \
    -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem -- --use-system-libraries
  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md History.txt -t "${pkgdir}/usr/share/doc/${pkgname}"

  cd "${pkgdir}/${_gemdir}"
  rm -rf cache gems/${_gemname}-${pkgver}/{ext,lib/*/*.so} \
    extensions/*/*/${_gemname}-${pkgver}/{mkmf.log,gem_make.out}
}

# vim: ts=2 sw=2 et:
